package com.wo2record.demo;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

public class StudentServiceImpl implements StudentService {

	@Autowired
	private SessionFactory sessionFactory;
	
	public Student login(Student student) {
		Student logStudent = (Student)sessionFactory.getCurrentSession().get(Student.class, student.getId());
		if(logStudent != null){
			return logStudent;
		}else{
			return null;
		}
	}

	@Transactional
	public String save(Student student) {
		sessionFactory.getCurrentSession().save(student);
		return student.getId();
	}

}
